#pragma once
#include "GlobalDefine.h"
#include "Object.h"
#include <vector>
#include <string>

namespace mray {

struct Triangle;

struct Vert{
	vec3 v,n; vec2 t;
};

struct Mesh : public BaseObject{
	Mesh(const std::string& filePath, bool regenNormal, BaseMaterial* pMtl, bool dSides);

	bool Hit(Ray& ray, Result* pResult = nullptr)const override {return false;}
	bool GetAABB(AABB& aabb)const override {return false;}

	friend struct Triangle;
	friend struct World;

private:
	
	void LoadFile(const std::string& filePath, bool regenNormal);

	std::vector<uint>		m_indices;
	std::vector<Vert>		m_verts;
	std::vector<Triangle>	m_triangles;
};

struct Triangle : public Collible{

	bool Hit(Ray& ray, Result* pResult = nullptr)const override;
	bool GetAABB(AABB& aabb)const override;

	friend struct Mesh;

private:
	Mesh*				m_pmesh;
	std::vector<Vert>*	m_pverts;
	uint*				m_ptr;
};

}